package com.otaku.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.otaku.admin.dao.entity.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select r.* from sys_role r " +
            "inner join sys_user_role ur on r.id = ur.role_id " +
            "inner join sys_user u on ur.user_id = u.id " +
            "where u.username = #{userName}")
    List<Role> findByUser(@Param("userName") String userName);

    @Select("select * from sys_role")
    List<Role> findAll();
}
